/////precompiled////////
#include "precompiled.h"
////////////////////////


#include "prs_FrmControl.h"
using namespace prs;

// TMessage_Control ///////////////////////////////////////////////////////////

//
TMessage_Control::TMessage_Control() {
  Sender = NULL;
} 
 
//
bool TMessage_Control::InControlType(EControlType V) {
  if (Sender) {
    return V == Sender->GetEControlType();
  }
  return false;
}

// TNodeFrmControl ////////////////////////////////////////////////////////////

//
void TNodeFrmControl::TNode_SetPropPointerValue(TAttrPointerBase &Attr,svl::TPointer *V) {
  if (&Attr == &Style) { 
    vStyle = dynamic_cast<TNodeStyle*>(V);
    return;
  }
  if (&Attr == &LocalStyle) { 
    vLocalStyle = dynamic_cast<TNodeStyle*>(V);
    return;
  }
  TNodeFrm::TNode_SetPropPointerValue(Attr,V);
}

//
svl::TPointer *TNodeFrmControl::TNode_GetPropPointerValue(TAttrPointerBase &Attr) {
  if (&Attr == &Style) { 
    return vStyle;
  }
  if (&Attr == &LocalStyle) { 
    return vLocalStyle;
  }
  return TNodeFrm::TNode_GetPropPointerValue(Attr);
}

// TNodeFrmControlEvents //////////////////////////////////////////////////////

//
void TNodeFrmControlEvents::Event(TBeforeKeyboardKey &Param) {
  TMessage_BeforeKeyboardKey M(Param.KeyboardKey);
    M.Sender = &control;
  TNodeUseTemplate::sendMessage(M);
}

//
void TNodeFrmControlEvents::Event(TAfterKeyboardKey &Param) {
  TMessage_AfterKeyboardKey M(Param.KeyboardKey);
    M.Sender = &control;
  TNodeUseTemplate::sendMessage(M);
}

//
void TNodeFrmControlEvents::Event(TBeforeKeyboardChar &Param) {
  TMessage_BeforeKeyboardChar M(Param.KeyboardChar);
    M.Sender = &control;
  TNodeUseTemplate::sendMessage(M);
}

//
void TNodeFrmControlEvents::Event(TAfterKeyboardChar &Param) {
  TMessage_AfterKeyboardChar M(Param.KeyboardChar);
    M.Sender = &control;
  TNodeUseTemplate::sendMessage(M);
}

//
void TNodeFrmControlEvents::Event(TSelectEnter &Param) {
  TMessage_SelectEnter M;
    M.Sender = &control;
  TNodeUseTemplate::sendMessage(M);
}
